package org.jawa.learning.dao;

import org.jawa.core.exception.NotFoundException;
import org.jawa.core.exception.UserNotFoundException;
import org.jawa.learning.model.User;
import org.jawa.learning.webapp.util.Page;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 用户信息相关操作类.
 *
 * @author YAK
 */
public interface UserDao extends GenericDao<User, Long> {

	/**
	 * 根据登录名称获取用户相关信息
	 * @param username 用户名
	 * @return User 用户的相关信息
	 * @throws NotFoundException 没有找到相关用户
	 */
	@Transactional
	User loadUserByUsername(String username) throws UserNotFoundException;

	/**
	 * Gets a list of users ordered by the uppercase version of their username.
	 *
	 * @return List populated list of users
	 */
	List<User> getUsers();
	
	/**
	 * 
	 * @param user
	 * @param page 
	 * @return
	 */
	Page<User> getUsers(User user, Page<User> page);
	
	/**
	 * 保存用户信息
	 * @param 用户信息
	 * @return 保存后的用户信息
	 */
	User saveUser(User user);

	User updateUser(User user) throws Exception;
	
	/**
	 * 返回用户的密码信息
	 * @param username username
	 * @return 如果用户存在返回用户密码字段信息
	 */
	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	String getUserPassword(String username);

	

}
